<template>
  <el-dialog
    :before-close="close_Change"
    :title="props.props_title_name"
    v-model="dialogVisible"
    width="60%"
  >
    <el-input
      v-model="log_info"
      :autosize="{ minRows: 2, maxRows: 4 }"
      type="textarea"
      placeholder="Please input"
    ></el-input>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="close_Change" size="mini">取 消</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import * as Request from "../../general/request";
import { ElMessage } from "element-plus";
import { ref, watch } from "vue";

export default {
  name: "sys_code",
  emits: ["childClick"],
  props: {
    soft_id: String,
    in_value: Boolean,
    soft_value: String,
  },
  setup(props, { emit }) {
    const log_info = ref([]);
    let dialogVisible = ref(props.in_value);

    const close_Change = () => {
      dialogVisible.value = false;
      emit("childClick");
    };

    watch(props, (new_val) => {
      dialogVisible.value = new_val.in_value;
      if (new_val.in_value) {
        get_soft_log();
      }
    });

    const get_soft_log = async () => {
      const response = await Request.GET(
        "/background/home/log_manage/log_info",
        { soft_id: props.soft_id }
      );
      if (response && response.data) {
        var return_data = response.data;
        if (return_data.success) {
          log_info.value = return_data.data;
          // ElMessage.success(return_data.msg)
        } else {
          ElMessage.error(return_data.msg);
        }
      }
    };

    // onMounted(get_soft_log)

    return {
      props,
      log_info,
      close_Change,
      dialogVisible,
    };
  },
};
</script>

<style scoped></style>
